package com.atguigu.gmall.weball.controller;

import com.atguigu.gmall.feign.product.CategoryFeignClient;
import com.atguigu.gmall.model.rpc.product.BaseCategory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class IndexController {

    @Autowired
    CategoryFeignClient categoryFeignClient;

    /**
     * 访问首页
     * @return
     */
    @RequestMapping({"/","/index"})
    public String index(Model model){

        //利用feign，给指定的微服务发送指定地址的请求
        List<BaseCategory> category = categoryFeignClient.getAllCategory();

        //首页需要的数据￥{list} 里面包装了（三级分类）
        //通过远程查询所有分类请
        model.addAttribute("list",category);
        return "index/index";
    }




}
